package com.wh1200.mybatis.xmlless.resolver

import com.wh1200.mybatis.xmlless.config.BaseResolverTest
import com.wh1200.mybatis.xmlless.enums.XmllessDbType
import com.wh1200.xmlless.test.dao.StudentDAO
import com.wh1200.xmlless.test.model.Student
import com.baomidou.mybatisplus.annotation.DbType
import org.junit.jupiter.api.Test
import kotlin.reflect.jvm.javaMethod
import kotlin.test.assertContains
import kotlin.test.assertNotNull

/**
 *
 * @author 吴昊
 * @date 2023/12/18 6:52
 * @since v0.0.0
 * @version 1.0
 */
class PostgreSqlResolveTest : BaseResolverTest(
    StudentDAO::class.java, XmllessDbType.POSTGRE_SQL
) {

  @Test
  fun resolveLimit() {
    val sql = createQueryForMethod(StudentDAO::findAllPageable.javaMethod!!).sql
    assertNotNull(sql)
    assertContains(sql, "LIMIT #{pageable.pageSize} OFFSET #{pageable.offset}")
    assert(!sql.contains("t_student.create_user_name"))
  }


  @Test
  fun selectJoinedEntityField() {
    val sql = createQueryForMethod(StudentDAO::findCreateUserName.javaMethod!!).sql
    assertNotNull(sql)
    assert(!sql.contains("t_student.create_user_name"))
  }

}
